using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PatientDomain;
using ShivamEMR.Model.DataInterfaces.PatientDataInterf;
using ShivamEMR.Model;

namespace ShivamEMR.Web.Areas.Patient.Controllers
{   
    public class InsuranceStatusController : Controller
    {
		private readonly IInsuranceStatusRepository insurancestatusRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public InsuranceStatusController() //: this(new InsuranceStatusRepository())
        {
            this.insurancestatusRepository = Registry.RepositoryFactory.GetInsuranceStatusRepository();
        }

        public InsuranceStatusController(IInsuranceStatusRepository insurancestatusRepository)
        {
			this.insurancestatusRepository = insurancestatusRepository;
        }

        //
        // GET: /InsuranceStatus/

        public ViewResult Index()
        {
            return View(insurancestatusRepository.All);//Including(insurancestatus => insurancestatus.Insurances));
        }

        //
        // GET: /InsuranceStatus/Details/5

        public ViewResult Details(int id)
        {
            return View(insurancestatusRepository.Find(id));
        }

        //
        // GET: /InsuranceStatus/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /InsuranceStatus/Create

        [HttpPost]
        public ActionResult Create(InsuranceStatus insurancestatus)
        {
            if (ModelState.IsValid) {
                insurancestatusRepository.Create(insurancestatus);
                insurancestatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /InsuranceStatus/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(insurancestatusRepository.Find(id));
        }

        //
        // POST: /InsuranceStatus/Edit/5

        [HttpPost]
        public ActionResult Edit(InsuranceStatus insurancestatus)
        {
            if (ModelState.IsValid) {
                insurancestatusRepository.Update(insurancestatus);
                insurancestatusRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /InsuranceStatus/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(insurancestatusRepository.Find(id));
        }

        //
        // POST: /InsuranceStatus/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var ist = insurancestatusRepository.Find(id);
            insurancestatusRepository.Delete(ist);
            insurancestatusRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

